<template>
  <el-dialog v-model="dialogVisible" :title="'预览'" width="700px" :append-to-body="true" :before-close="handleClose">
    <div class="dialog-body">
      <div v-html="objs.contractTemplate"></div>
      <div class="address">
        <div class="item">邮寄地址：{{  objs.mailingAddress }}</div>
        <div class="item">邮编：{{  objs.postalCode }}</div>
        <div class="item">业务电话：{{  objs.businessPhone }}</div>
        <div class="item">财务电话：{{  objs.earningsCall }}</div>
      </div>
      <div class="footers">
        <div class="box">
          <div class="items">
          甲方（签章）：
        </div>
        <div class="items">
          担保人：
        </div>
        <div class="items" style="width: 50%;">
          乙方（车主或司机签章）：
        </div>
        </div>
        <div class="boxs">
          <div class="items" style="width: 50%;">
           合同签订日期：        年      月      日

          </div>
        </div>
        <div class="image">
        <img :src="objs.officialSeal" style="width: 150px;" />
      </div>
      </div>
      
    </div>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="handleClose()">关闭</el-button>
        
      </span>
    </template>
  </el-dialog>
</template>

<script lang="ts" setup>
import { REQUEST } from '@/api/request'
import { store } from '@/store'
import { ref } from 'vue'
const title = ref('')
const dialogVisible = ref(false)
const emits = defineEmits(['ok'])
const content = ref('')
const url = ref('')
const openModal = ( data: any) => {
  dialogVisible.value = true
getData()
}
const objs = ref({})
const getData = ()=>{
  REQUEST.POST('OFFICIALINFO', {
    id:store.state.userInfo.houseId
  }).then((res: any) => {
    if (res.status == 200) {
    objs.value = res.data
    }
  })
}
const handleClose = () => {
  dialogVisible.value = false
  emits('ok')
}

defineExpose({ openModal })
</script>

<style lang="scss" scoped>
  .address{
    width: 100%;
    margin-top: 10px;
    color: #000000;
    overflow: hidden;
    .item{
      float: left;
      display: block;
      margin-right: 20px;
    }
  }
  .footers{
    padding: 20px 0;
    position: relative;
    .image{
      position: absolute;
      top: 0;
      left: 20px;
    }
    .box{
      width: 100%;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .items{
        width:25%;
        color: #000000;
        font-weight: bold;
      }
    }
    .boxs{
      display: flex;
      margin-top: 10px;
      justify-content: flex-end;
      color: #000000;
      font-weight: bold;
    }
  }
</style>
